package com.ccit.model;

import com.alibaba.fastjson.JSONObject;

/**
 * permission实体类
 * 
 * @author 
 *
 */
public class Permission {
	/***/
	private Integer id; 
	/***/
	private String name; 
	/***/
	private String resource; 
	/**
	 * 实例化
	 */
	public Permission() {
		super();
	}
	/**
	 * 实例化
	 * 
	 * @param obj
	 */
	public Permission(JSONObject obj) {
		this();
		if (obj.get("id") instanceof Number) {
			this.setId(((Number) obj.get("id")).intValue());
		}
		if (obj.get("name") instanceof String) {
			this.setName((String) obj.get("name"));
		}
		if (obj.get("resource") instanceof String) {
			this.setResource((String) obj.get("resource"));
		}
	}
	
	/**
	 * 将当前对象转换为JsonObject
	 * 
	 * @return
	 */
	public JSONObject toJson() {
		JSONObject result = new JSONObject();
		if (this.getId() != null) {
			result.put("id",this.getId());
		}
		if (this.getName() != null) {
			result.put("name",this.getName());
		}
		if (this.getResource() != null) {
			result.put("resource",this.getResource());
		}
		return result;
	}
	
	
	/**
	 * 获取id
	 * 
	 * @return
	 */
	public Integer getId() {
		return id;
	}

	/**
	 * 设置id
	 * 
	 * @param id
	 */
	public void setId(Integer id) {
		this.id = id;
	}
	
	/**
	 * 获取name
	 * 
	 * @return
	 */
	public String getName() {
		return name;
	}

	/**
	 * 设置name
	 * 
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * 获取resource
	 * 
	 * @return
	 */
	public String getResource() {
		return resource;
	}

	/**
	 * 设置resource
	 * 
	 * @param resource
	 */
	public void setResource(String resource) {
		this.resource = resource;
	}

	@Override
	public String toString() {
		return "Permission [id=" + id + " , name=" + name + " , resource=" + resource + "  ]";
	
	}
	
	
}
